<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script>

description("This tests the constructor for the CustomEvent DOM class.");

// No initializer passed.
shouldBe("new CustomEvent('eventType').bubbles", "false");
shouldBe("new CustomEvent('eventType').cancelable", "false");
shouldBeNull("new CustomEvent('eventType').detail");

// Bubbles and cancelable true, details is missing.
shouldBe("new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles", "true");
shouldBe("new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable", "true");
shouldBeNull("new CustomEvent('eventType', { bubbles: true, cancelable: true }).detail");

// Detail is a number
shouldBe("new CustomEvent('eventType', { detail: 10 }).detail", "10");

// Detail is a string
shouldBe("new CustomEvent('eventType', { detail: \'string\' }).detail", "'string'");

// Detail is an object
var detailObject = { };
shouldBe("new CustomEvent('eventType', { detail: detailObject }).detail", "detailObject");

// Detail is a DOM object
shouldBe("new CustomEvent('eventType', { detail: document }).detail", "document");

// Detail is undefined. Since the default value of detail is null, it should
// result in "null".
shouldBe("new CustomEvent('eventType', { detail: undefined }).detail", "null");

// Detail is null.
shouldBe("new CustomEvent('eventType', { detail: null }).detail", "null");

// Detail is a getter.
shouldBe("new CustomEvent('eventType', { get detail() { return true; } }).detail", "true");

// Detail throws an exeception.
shouldThrow("new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } })");
</script>
</body>
</html>
